// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({
  env:"cloud1-7gb9s3y025614beb"
})

// 云函数入口函数
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()
  let openid = wxContext.OPENID
  const db = cloud.database()
  const studentCollection = db.collection('pc_student')
  let res = await studentCollection.where({
    openid
  }).get()
let result = {}
if(res.data.length>0){
  result = res.data[0]
}else{
  result = {name:'nobody'}
}
  return {
    result
  }
}